package www.dianbaozu.com.ui.server.findMember.adapter

import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.netease.nim.uikit.R
import com.netease.nim.uikit.api.NIMHelper
import com.netease.nim.uikit.api.SessionHelper
import com.netease.nim.uikit.business.uinfo.UserInfoHelper
import com.netease.nim.uikit.common.ui.dialog.CustomAlertDialog
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseSectionQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder
import com.netease.nim.uikit.databinding.ItemFriendsBinding
import com.netease.nimlib.sdk.friend.model.Friend
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
import com.netease.nimlib.sdk.search.model.MsgIndexRecord
import www.dianbaozu.com.ui.chat.findFriend.holder.FindFriendRecentContactViewHolder
import www.dianbaozu.com.ui.chat.findFriend.holder.FindFriendViewHolder
import www.dianbaozu.com.ui.chat.findFriend.holder.HeaderViewHolder
import www.wen.com.common.lib.data.entities.ServiceMemberEntity
import www.wen.com.common.lib.data.entities.UseInfoEntity
import www.wen.com.common.lib.extension.getDrawableAgency
import www.wen.com.common.lib.extension.glide.setImageUrl

class FindMemberAdapter(
    recyclerView: RecyclerView,
    layoutId: Int,
    data: List<ServiceMemberEntity>
) :
    BaseQuickAdapter<ServiceMemberEntity, BaseViewHolder>(recyclerView, layoutId, data) {
    private var binding: ItemFriendsBinding? = null

    override fun convert(
        helper: BaseViewHolder,
        item: ServiceMemberEntity,
        position: Int,
        isScrolling: Boolean
    ) {
        binding = DataBindingUtil.bind(helper.itemView)
        binding?.apply {
            tvSubtitle.visibility = View.GONE
            imgArrow.visibility = View.GONE
            tvTopStatus.visibility = View.GONE
            slUnreadMessage.visibility = View.GONE
            imgOnlineStatus.visibility = View.VISIBLE

            setImageUrl(
                view = ivAvatar,
                error = getDrawableAgency(R.drawable.user_default_icon),
                source = item.avatar
            )

            imgOnlineStatus.setImageResource(if (item.onlineStatus)
                R.drawable.ic_circle_green_middle_1 else
                R.drawable.ic_circle_gray_middle_1)
            tvTitle.text = item.nickName
            helper.addOnClickListener(R.id.constraintLayout)
        }
    }

}